package com.amumu.drama.common.modules.fuioupay.constant;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;

/**
 * @author sunzhuang
 * @date 2024/8/9 10:59
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc todo
 */

@Getter
public enum FuiouOrderStatusEnum {
    ORDER_STATUS0(0, "订单未支付(初始化状态)"),
    ORDER_STATUS1(1, "订单支付成功"),
    ORDER_STATUS2(2, "订单支付失败"),
    ORDER_STATUS3(3, "订单支付超时"),
    ORDER_STATUS4(4, "订单关闭(过期)"),
    ORDER_STATUS5(5, "订单已全额退款"),
    ORDER_STATUS6(6, "订单已部分退款"),
    ORDER_STATUS7(7, "其他退款失败"),
    ORDER_STATUS8(8, "退款申请成功，对账处理"),
    ORDER_STATUS9(9, "退款申请成功，人工处理"),
    ;

    private Integer code;
    private String desc;

    FuiouOrderStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static Map<Integer, FuiouOrderStatusEnum> UNINDEX = Maps.uniqueIndex(Arrays.asList(values()), FuiouOrderStatusEnum::getCode);

    public static String getDescByCode(Integer code) {
        FuiouOrderStatusEnum fuiouOrderStatusEnum = UNINDEX.get(code);
        return fuiouOrderStatusEnum == null ? null : fuiouOrderStatusEnum.getDesc();
    }
}
